<template>
  <PageWrapper contentFullHeight>
    <ListTemplate :register-table="registerTable" :method="methods" :showAddBtn="false">
      <template #extendTableTitle>{{ group?.title }}</template>
    </ListTemplate>
  </PageWrapper>
</template>
<script setup lang="ts">
  import PageWrapper from '@/components/Page/src/PageWrapper.vue';
  import ListTemplate from '@/views/common/operate/listTemplate.vue';
  import ApiV1 from '@/views/common/operate/ApiV1';
  import { dplist, findone } from '@/views/dp_platform/qiangua.api';
  import { useDplistColumns } from '@/views/dp_platform/qiangua.data';
  import { onMounted, ref } from 'vue';
  import { useRoute } from 'vue-router';

  const group = ref<object>({});
  defineOptions({
    name: 'DpListIndex',
  });

  const { registerTable, methods, tableMethods } = ApiV1.useList({
    tableProps: {
      api: dplist,
      columns: useDplistColumns(),
      useSearchForm: false,
      showActionColumn: false,
      immediate: false,
      beforeEditSubmit: async ({ record, index, key, value }) => {
        console.log(record, index, key, value);
      },
    },
  });
  const gid = ref('');
  const route = useRoute();
  onMounted(async () => {
    const { groupId } = route.query;
    if (groupId) {
      gid.value = groupId.toString();
      group.value = await findone(parseInt(gid.value));
      tableMethods.setProps({ searchInfo: { groupId: groupId } });
      await tableMethods.reload();
    }
  });
</script>
<style scoped lang="less"></style>
